1 <!DOCTYPE html PUBLIC
"-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
4 <meta http-equiv=
"Content-Type" content=
"text/html; charset=UTF-8">
5 <meta http-equiv=
"Content-Style-Type" content=
"text/css">
7 <meta name=
"Generator" content=
"Cocoa HTML Writer">
8 <meta name=
"CocoaVersion" content=
"1038.25">
9 <style type=
"text/css">
10 p
.p1
{margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Helvetica
}
11 p
.p2
{margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica
; min-height: 14.0px}
12 p
.p3
{margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica
}
13 p
.p4
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; min-height: 12.0px}
14 p
.p5
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
}
15 p
.p6
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #bf0000}
16 p
.p7
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #606060}
17 p
.p8
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #a91616}
18 span
.s1
{color: #0000bf}
19 span
.s2
{color: #000000}
20 span
.s3
{color: #007300}
21 span
.s4
{color: #0014bc}
22 span
.s5
{color: #307109}
23 span
.Apple-tab-span
{white-space:pre
}
27 <p class=
"p1"><b>Warp1
<span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>Warp a buffer with a time pointer
</b></p>
28 <p class=
"p2"><br></p>
29 <p class=
"p3">Inspired by Chad Kirby's SuperCollider2 Warp1 class, which was inspired by Richard Karpen's sndwarp for CSound. A granular time strecher and pitchshifter.
</p>
30 <p class=
"p2"><br></p>
31 <p class=
"p3"><b>Warp1.ar(numChannels, bufnum, pointer, freqScale, windowSize, envbufnum, overlaps,
<span class=
"Apple-converted-space"> </span></b></p>
32 <p class=
"p3"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>windowRandRatio, interp, mul, add)
</b></p>
33 <p class=
"p2"><br></p>
34 <p class=
"p3"><span class=
"Apple-tab-span"> </span><b>numChannels
</b> - the number of channels in the soundfile used in bufnum.
</p>
35 <p class=
"p3"><span class=
"Apple-tab-span"> </span><b>bufnum
</b> - the buffer number of a mono soundfile.
</p>
36 <p class=
"p3"><span class=
"Apple-tab-span"> </span><b>pointer
</b> - the position in the buffer.
<span class=
"Apple-converted-space"> </span>The value should be between
0 and
1, with
0 being the begining
</p>
37 <p class=
"p3"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>of the buffer, and
1 the end.
</p>
38 <p class=
"p3"><span class=
"Apple-tab-span"> </span><b>freqScale
</b>- the amount of frequency shift.
1.0 is normal,
0.5 is one octave down,
2.0 is one octave up.
</p>
39 <p class=
"p3"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>Negative values play the soundfile backwards.
</p>
40 <p class=
"p3"><span class=
"Apple-tab-span"> </span><b>windowSIze
</b> - the size of each grain window.
</p>
41 <p class=
"p3"><b><span class=
"Apple-tab-span"> </span>envbufnum
</b> - the buffer number containing a singal to use for the grain envelope. -
1 uses a built-in
<span class=
"Apple-converted-space"> </span></p>
42 <p class=
"p3"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>Hanning envelope.
</p>
43 <p class=
"p3"><span class=
"Apple-tab-span"> </span><b>overlaps
</b> - the number of overlaping windows.
</p>
44 <p class=
"p3"><b><span class=
"Apple-tab-span"> </span>windowRandRatio
</b>- the amount of randomness to the windowing function.
<span class=
"Apple-converted-space"> </span>Must be between
0 (no
</p>
45 <p class=
"p3"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>randomness) to
1.0 (probably to random actually)
</p>
46 <p class=
"p3"><b><span class=
"Apple-tab-span"> </span>interp -
<i> </i></b>the interpolation method used for pitchshifting grains.
1 = no interpolation.
2 = linear.
<span class=
"Apple-converted-space"> </span></p>
47 <p class=
"p3"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>4 = cubic interpolation (more computationally intensive).
</p>
48 <p class=
"p2"><br></p>
49 <p class=
"p2"><br></p>
50 <p class=
"p3"><b>Examples:
</b></p>
51 <p class=
"p4"><br></p>
52 <p class=
"p5">s.boot;
</p>
53 <p class=
"p4"><br></p>
55 <p class=
"p5"><span class=
"s1">var
</span> winenv;
</p>
56 <p class=
"p6">// a custom envelope - not a very good one, but you can hear the difference between this
<span class=
"Apple-converted-space"> </span></p>
57 <p class=
"p6">// and the default
</p>
58 <p class=
"p5">winenv =
<span class=
"s1">Env
</span>([
0,
1,
0], [
0.5,
0.5], [
8, -
8]);
</p>
59 <p class=
"p7"><span class=
"s2">b =
</span><span class=
"s1">Buffer
</span><span class=
"s2">.read(s,
</span>"sounds/a11wlk01-44_1.aiff"<span class=
"s2">);
</span></p>
60 <p class=
"p5">z =
<span class=
"s1">Buffer
</span>.sendCollection(s, winenv.discretize,
1);
</p>
61 <p class=
"p4"><br></p>
62 <p class=
"p5"><span class=
"s1">SynthDef
</span>(
<span class=
"s3">\warp
</span>, {
<span class=
"s1">arg
</span> buffer =
0, envbuf = -
1;
</p>
63 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"s1">var
</span> out, pointer, filelength, pitch, env, dir;
</p>
64 <p class=
"p6"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>// pointer - move from beginning to end of soundfile over
15 seconds
</p>
65 <p class=
"p5"><span class=
"Apple-tab-span"> </span>pointer =
<span class=
"s1">Line
</span>.kr(
0,
1,
15);
</p>
66 <p class=
"p6"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>// control pitch with MouseX
</p>
67 <p class=
"p5"><span class=
"Apple-tab-span"> </span>pitch =
<span class=
"s1">MouseX
</span>.kr(
0.5,
2);
</p>
68 <p class=
"p5"><span class=
"Apple-tab-span"> </span>env =
<span class=
"s1">EnvGen
</span>.kr(
<span class=
"s1">Env
</span>([
0.001,
1,
1,
0.001], [
0.1,
14,
0.9],
<span class=
"s3">'exp'
</span>), doneAction:
2);
</p>
69 <p class=
"p5"><span class=
"Apple-tab-span"> </span>out =
<span class=
"s1">Warp1
</span>.ar(
1, buffer, pointer, pitch,
0.1, envbuf,
8,
0.1,
2);
</p>
70 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"s1">Out
</span>.ar(
0, out * env);
</p>
71 <p class=
"p5">}).send(s);
</p>
72 <p class=
"p4"><br></p>
74 <p class=
"p4"><br></p>
75 <p class=
"p8">// use built-in env
</p>
76 <p class=
"p5">x =
<span class=
"s4">Synth
</span>(
<span class=
"s5">\warp
</span>, [
<span class=
"s5">\buffer
</span>, b,
<span class=
"s5">\envbuf
</span>, -
1])
</p>
77 <p class=
"p4"><br></p>
78 <p class=
"p8">// switch to the custom env
</p>
79 <p class=
"p5">x.set(
<span class=
"s5">\envbuf
</span>, z)
</p>
80 <p class=
"p5">x.set(
<span class=
"s5">\envbuf
</span>, -
1);
</p>
81 <p class=
"p4"><br></p>
82 <p class=
"p5">x.free;
</p>